Skip to content

feat(server): add PostgreSQL storage and embedding server - #417

Open
Traviis wants to merge 18 commits into
flupkede:developfrom
Traviis:features/server-foundation
Open

Traviis wants to merge 18 commits into
flupkede:developfrom
Traviis:features/server-foundation

Conversation

@Traviis

@Traviis Traviis commented Nov 26, 2026

Copy link
Copy Markdown
Collaborator

Summary

Implements the PostgreSQL server foundation requested in stage 2 of #384, adapting the storage work from #365 onto the merged core split. Internal review: Traviis#1.

  • Runnable codesearch-server with server-owned SQLx/pgvector dependencies; standalone CLI keeps its local storage path.
  • Server-side embedding through shared core local/OpenAI-compatible providers.
  • PostgreSQL persistence for vectors, pg_search BM25, prepared documents, embedding cache, repository metadata and incremental file state.
  • Transactional per-file replacement/deletion with revision CAS, tombstones, deterministic shared-cache lock order and interruption recovery.
  • Scoped keyword/vector/hybrid HTTP queries and paginated repository/file enumeration.
  • Loopback-only listener with Host/Origin validation; no authentication yet.

Boundaries and decisions for review

This PR is the storage/server foundation, not the remaining roadmap. Authentication, federation/MCP integration, thin-client publishing, designated-indexer scheduling and working-copy namespaces remain separate stages. The HTTP endpoints exercise the foundation; they are not the final chunk-publisher/federation protocol.

Two implementation choices to call out:

  • Vector retrieval currently uses exact cosine scans, rather than the original HNSW path. This avoids filtered ANN underfill but is not company-scale performance qualification.
  • Publication/recovery is per file, not repository-wide snapshot publication. Source revision is caller-supplied; ambiguous COMMIT outcomes require reading durable state before retrying.

Requires pg_search 0.27.1 and pgvector >=0.8. Database embedding/document identity mismatches are rejected without destructive resets; incompatible identities require intentional reindex into a separate database. Setup and current HTTP contract: server/README.md.

Independent server release automation remains outstanding. Service must not be exposed to untrusted/network callers before authentication is implemented.

Correctness coverage

Behavioral regressions cover final prepared-document cache identity (including long-function rename/split headers), extracted documentation persistence/search, explicit nullable deletion payloads, malformed notebook preservation, physical inclusive split-source ranges, pagination beyond1000 repositories, repeated pg_search prepared queries and deterministic shared-cache insertion order. Core changes expose shared provider/document preparation and narrowly correct split source coordinates; notebook execution is not introduced.

Verification

Passed on the reviewed functional tree:

  • cargo fmt --all -- --check
  • cargo clippy --workspace --all-targets -- -D warnings
  • cargo test --workspace --lib --bins: 436 +433 +744 +8 passed, existing ignored tests retained.
  • Explicit real-extension server tests: 17 passed,0failed,0ignored, including cargo test -p codesearch-server --no-default-features --features load-dynamic --lib -- --include-ignored --nocapture.
  • Core chunker tests: 58 passed.
  • Actual PostgreSQL 18.7, pg_search 0.27.1, pgvector 0.8.6, with real LiteLLM text-embedding-3-small1024-dimensional inference:14 source files across5 repositories,174 chunks. Seven source-grounded questions evaluated in vector/hybrid modes: expected source in top5 for14/14 evaluations (13rank1,one rank3).
  • Live update/delete/CAS/cache checks and graceful physical database/binary restart passed.

Failure-isolation integration tests use an explicitly simulated deterministic HTTP embedding provider; the separate live-corpus run uses actual inference. No scale, abrupt database crash, backup restore, local ONNX inference or production TLS qualification claimed. Test-command-only Git signing disabled for disposable Git fixtures; no user configuration changes. Temporary Nix tooling used, no repository Nix setup.

Fresh independent full-diff review read the complete #365/#384 discussion without prior reviewer reports and found no issues; this is review evidence, not maintainer acceptance. Subsequent edits only restored the package description and made the server README operational rather than historical.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant